/*
 * @Author: wjc
 * @Date: 2025-02-13 14:52:31
 * @LastEditors: wjc
 * @LastEditTime: 2025-10-28 17:42:47
 * @Description:
 */
/**
 * 表单验证错误类
 *
 * @author Charsen
 * @date 2020-02-27
 */
export default class Validation {
  messages: object = {}

  constructor() {
    this.messages = {}
  }
  clean() {
    this.messages = {}
  }
  err(field: string) {
    if (this.messages && Object.prototype.hasOwnProperty.call(this.messages, field)) {
      return this.messages[field as PickKeysEnum<typeof this.messages>][0]
    }
    return undefined
  }
  setMessages(messages: object) {
    this.clean()
    this.messages = messages
  }
}
